unit FormHint;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type

  TWmMoving = record
    Msg: Cardinal;
    fwSide: Cardinal;
    lpRect: PRect;
    Result: Integer;
  end;


  TfrmHint = class(TForm)
    Label1: TLabel;
    procedure FormShow(Sender: TObject);
    procedure FormMouseMove(Sender: TObject; Shift: TShiftState; X,
      Y: Integer);
    procedure WMNCMOUSEMOVE(var Message: TMessage); message WM_NCMOUSEMOVE;
    procedure WMMoving(var msg: TWMMoving); message WM_MOVING;
  private
    { Private declarations }
  public
    frmMain: TForm;
  end;

var
  frmHint: TfrmHint;

implementation

{$R *.dfm}

procedure TfrmHint.FormShow(Sender: TObject);
begin
  Self.AlphaBlend := true;
  Self.AlphaBlendValue := 128;
end;

procedure TfrmHint.FormMouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
begin
  Self.AlphaBlendValue := 255;
end;

procedure TfrmHint.WMNCMOUSEMOVE(var Message: TMessage);
begin
  if Message.wParam in [HTCAPTION, HTBORDER, HTCLOSE] then
    Self.AlphaBlendValue := 255;
  Message.Result := 0;
  inherited;
end;

procedure TfrmHint.WMMoving(var msg: TWMMoving);
var
   r: TRect;
begin
  r := Rect(frmMain.BoundsRect.Left + 20, frmMain.BoundsRect.Top + 100,
    frmMain.BoundsRect.Right - 20, frmMain.BoundsRect.Bottom - 40);
  if msg.lprect^.left < r.left then
     OffsetRect(msg.lprect^, r.left - msg.lprect^.left, 0);
  if msg.lprect^.top < r.top then
     OffsetRect(msg.lprect^, 0, r.top - msg.lprect^.top);
  if msg.lprect^.right > r.right then
     OffsetRect(msg.lprect^, r.right - msg.lprect^.right, 0);
  if msg.lprect^.bottom > r.bottom then
     OffsetRect(msg.lprect^, 0, r.bottom - msg.lprect^.bottom);
  inherited;
end;

end.
